package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.TProdSuggest;
import com.ruoyi.system.domain.dto.TProdSuggestDTO;
import com.ruoyi.system.domain.vo.TProdRecordSuggestVO;
import com.ruoyi.system.mapper.TProdSuggestMapper;
import com.ruoyi.system.service.ITProdSuggestService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TProdSuggestServiceImpl extends ServiceImpl<TProdSuggestMapper, TProdSuggest> implements ITProdSuggestService {
    @Override
    public List<TProdRecordSuggestVO> getProdAndSuggest(TProdSuggestDTO params) {
        return this.baseMapper.getProdAndSuggest(params);
    }

    @Override
    public void add(TProdSuggestDTO.TProdSuggestAddDTO params) {
        //将其他数据状态置为历史，然后添加一条最新
        this.baseMapper.updateStatusByTaskCode(params.getProdId());
        TProdSuggest entity = new TProdSuggest();
        BeanUtils.copyProperties(params,entity);
        entity.setStatus(1);
        this.baseMapper.insert(entity);
    }
}
